package com.aegis.gateway.constants;

import cn.dev33.satoken.reactor.filter.SaReactorFilter;
import com.aegis.gateway.filter.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.core.Ordered;
import org.springframework.web.server.WebFilter;

/**
 * @Author wuweixin
 * @Version 1.0
 * @Descritube
 */
@Getter
@AllArgsConstructor
public enum FilterChainEnum {

    /**
     * 这个-100是默认值，暂时改动无效，后续可通过继承更改执行顺序
     */
    BEFORE_FILTER(BeforeWebFilter.class, Ordered.HIGHEST_PRECEDENCE, "前置过滤器"),
    SA_FILTER(SaReactorFilter.class, -100, "用户身份认证的过滤器"),
    /**
     * 分发过滤器只能分发优先级比他低的过滤器
     */
    DISTRIBUTE_FILTER(DistributeSignatureFilter.class, 0, "分发摘要鉴权请求的前置过滤器"),
    SIGN_FILTER(SignFilter.class, 1, "签名校验的过滤器"),
    AFTER_FILTER(AfterWebFilter.class, Ordered.LOWEST_PRECEDENCE, "后置过滤器"),
    ;

    private final Class<? extends WebFilter> filterClass;
    private final int order;
    private final String desc;


}
